package zhongbo.java.air.flightpath.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.flightpath.listener.RedisSubscribeLogChaneIListener;
import zhongbo.java.air.flightpath.listener.RedisSubscribeMyChaneIListener;

@Configuration
@Slf4j
public class RedisListenerConfig {
    public static String LOG_CHANNEL = "log_channel";
    public static String INJEST_CHANNEL = "injest_path_chanel_zhang_hong_ying";

    public static String LIVE_PATH = "live_flight_path_zhang_hong_ying";


    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChaneIListener logChaneIListener,
                               RedisSubscribeMyChaneIListener   myChaneIListener) {
        log.info("配置redis监听器");
        Topic logTopic = new PatternTopic(LOG_CHANNEL);
        Topic myTopic = new PatternTopic(INJEST_CHANNEL);

        listenerContainer.addMessageListener(logChaneIListener, logTopic);
        listenerContainer.addMessageListener(myChaneIListener, myTopic);
    }
}
